﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MonsterEngine.Entities;
using MonsterEngine.Adapters;
using MongoDB.Bson.Serialization;
using MonsterEngine.Interfaces;
using MonsterEngine.Abilities;

namespace MonsterEngine.Managers
{
    public class AccountManager
    {
        public AccountManager()
        {
        }

        public bool InsertAccount(Account accountObj)
        {
            MongoAdapter<Account> act = new MongoAdapter<Account>();
            if (act.GetListObjects("Name", accountObj.Name).Count() == 0)
            {
                act.InsertObject(accountObj);
                return true;
            }
            return false; //Account exists
        }

        /// <summary>
        /// This will require serious changes to how the program operates to 
        /// support accounts rather than individual chars.
        /// </summary>
        /// <param name="accountName"></param>
        /// <returns></returns>
        public Account GetAccount(string accountName)
        {
            MongoAdapter<Account> mAdp = new MongoAdapter<Account>();
            List<Account> account = mAdp.GetListObjects("Name", accountName);
            return account.FirstOrDefault();
        }
    }
}
